home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Essentials / Developer Essentials Nov 90 / Apple II / Apple.II.partition / Tools / Technical.Notes / IIGS / TN.IIGS.083 < prev    next >
Encoding:
Text File  |  1990-09-21  |  4.3 KB  |  103 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6. Apple IIgs
  7. #83:    Resource Manager Stuff
  8.  
  9. Revised by:    Dave "Eh?" Lyons                                September 1990
  10. Written by:    Dave Lyons                                            May 1990
  11.  
  12. This Technical Note answers your miscellaneous Resource Manager questions.
  13. Changes since July 1990:  Added note that LoadResource with SetResLoad(FALSE) 
  14. can return lockErr, and added warning about adjusting the search depth.
  15. _____________________________________________________________________________
  16.  
  17.  
  18. What SetCurResourceFile Does
  19.  
  20. SetCurResourceFile is documented in Chapter 45 of the Apple IIgs Toolbox 
  21. Reference, Volume 3 (see especially "Resource File Search Sequence" near the 
  22. beginning of the chapter).
  23.  
  24. This explanation might make you think SetCurResourceFile rearranges the search 
  25. path, but it does not; instead, it just makes searches start at a different 
  26. place in the path.  SetCurResourceFile is useful for controlling what resource 
  27. files are searched, not for changing the search order.
  28.  
  29.  
  30. How the Toolbox Uses Resources as Templates
  31.  
  32. The toolbox uses several types of resources as templates for creating other 
  33. objects.  Examples include rControlList, rControlTemplate, and rWindParam1.  
  34. The toolbox automatically releases these resources from memory as soon as it 
  35. is through with them, so there is no need to create your template resources 
  36. with special purge levels in an effort to free more memory.  It is not a 
  37. problem.
  38.  
  39.  
  40. StartUpTools Opens Resource Forks Read-Only
  41.  
  42. When StartUpTools opens your application's resource fork, it opens it with 
  43. read-only access.  If your application needs to make changes to the resources 
  44. on disk, you need to close the fork and reopen it with read and write access.  
  45. To close it, use GetCurResourceFile and CloseResourceFile; to reopen it, use 
  46. LGetPathname2 and OpenResourceFile.
  47.  
  48.  
  49.  
  50. Calling StartUpTools From a Shell Application (File Type $B5, EXE)
  51.  
  52. StartUpTools tries to open the current application's resource fork.  It 
  53. determines the pathname of the "current application" by examining prefix 9: 
  54. and making a GET_NAME GS/OS call, but do not assume it will always construct 
  55. the pathname this way.  If you call StartUpTools from a shell application and 
  56. expect it to open your EXE file's resource fork, you will be disappointed.
  57.  
  58. If GS/OS has launched your application, life is good--usually, though, a shell 
  59. has loaded your shell application directly, so GET_NAME returns the name of 
  60. the shell instead of the name of your application file.
  61.  
  62. To open your shell file's resource fork, call ResourceStartUp, get the 
  63. pathname by calling LGetPathname2 on your user ID, and pass the pathname to 
  64. OpenResourceFile.
  65.  
  66.  
  67. What's NIL in a Resource Map?
  68.  
  69. The resource maps for open resource files are kept in memory, and the 
  70. structure is defined in chapter 45 of Apple IIgs Toolbox Reference, Volume 3.
  71.  
  72. The resHandle field of a resource reference record (ResRefRec) is defined as 
  73. "Handle of resource in memory.  A NIL value indicates that the resource has 
  74. not been loaded into memory."  In this case, NIL means that the middle two 
  75. bytes of the four-byte field are zero.  In other words, a NIL entry in the 
  76. resource map may have a non-zero value in the low-order byte.
  77.  
  78. LoadResource and SetResLoad(FALSE)
  79.  
  80. When you call LoadResource on a locked or fixed resource and SetResLoad is set 
  81. to FALSE, you may get Memory Manager error $0204 (lockErr), because the 
  82. Resource Manager tries to allocate a locked or fixed zero-length handle, which 
  83. the Memory Manager does not permit.
  84.  
  85.  
  86. Adjusting the Search Depth
  87.  
  88. If you wish to add some resource files to the beginning of a resource search 
  89. path and adjust the depth so that the end point of the search is unchanged, 
  90. it's tempting to use SetResourceFileDepth(0) to get the current depth, add 
  91. one, and set this new depth with SetResourceFileDepth.
  92.  
  93. The problem is that the search depth is often -1 ($FFFF), meaning "search 
  94. until the end of the chain."  If you add your adjustment to -1, you do not 
  95. usually get the intended effect.  A solution is just to check for $FFFF and 
  96. not adjust the depth in that case.
  97.  
  98.  
  99. Further Reference
  100. _____________________________________________________________________________
  101.   o  Apple IIgs Toolbox Reference, Volume 3
  102.  
  103.